package com.xbongbong.paas.model.impl;

import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.model.ContractTemplateBaseModel;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.domain.dao.ContractEditFileDao;
import com.xbongbong.saas.domain.dao.ContractTemplateBaseDao;
import com.xbongbong.saas.domain.entity.ContractEditFileEntity;
import com.xbongbong.saas.domain.entity.ContractTemplateBaseEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: yingjf
 * @date: 2023/3/7 19:21
 * @description:
 */
@Service("contractTemplateBaseModel")
public class ContractTemplateBaseModelImpl implements ContractTemplateBaseModel {
    @Resource
    private ContractTemplateBaseDao contractTemplateBaseDao;

    @Override
    public Long insert(ContractTemplateBaseEntity entity) {
        long now = DateTimeUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return contractTemplateBaseDao.insert(entity);
    }

    @Override
    public void insertBatch(List<ContractTemplateBaseEntity> list) {
        contractTemplateBaseDao.insertBatch(list);
    }

    @Override
    public List<ContractTemplateBaseEntity> findEntities(Map<String, Object> param) {
        return contractTemplateBaseDao.findEntities(param);
    }

    @Override
    public Integer getEntityCount(Map<String, Object> param) {
        return contractTemplateBaseDao.getEntitiesCount(param);
    }

    @Override
    public void update(ContractTemplateBaseEntity entity) {
        contractTemplateBaseDao.update(entity);
    }

    @Override
    public ContractTemplateBaseEntity getByKey(Long key, String corpid) {
        return contractTemplateBaseDao.getByKey(key, corpid);
    }

    @Override
    public Integer getCountByCorpid(String corpid) {
        Map<String,Object> params = new HashMap<>();
        params.put(StringConstant.CORPID,corpid);
        params.put(StringConstant.DEL, DelEnum.NORMAL.getDel());
        return contractTemplateBaseDao.getEntitiesCount(params);
    }
}
